package member.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import member.model.service.MemberService;
import member.to.ActionForward;
import member.to.MemberTO;

public class JoinMemberController implements Controller {
	
	@Override
	public ActionForward handle(HttpServletRequest request, HttpServletResponse response) {
		ActionForward af = null;
		//1. 요청파라미터 조회
		MemberTO mto = (MemberTO)request.getAttribute("mto");
		mto.setMileage(1000);
		//2. Business Logic 처리 - mms.joinMember()
		MemberService mms = MemberService.getInstance();
		try {
			mms.joinMember(mto);
//			request.setAttribute("mto", mto);
			af = new ActionForward("/join_success.jsp", false);
		} catch (Exception e) {
			e.printStackTrace();
			request.setAttribute("error_message", e.getMessage());
			af = new ActionForward("/error.jsp", false);
		}
		return af;
	}

}
